package com.zhongpengcheng.blog.auth;

import org.apache.shiro.authc.UsernamePasswordToken;

/**
 * 鉴权Token对象
 * note: 1.记录变更 by zhongpengcheng
 *
 * @author zhongpengcheng
 * @date 2021/08/13 16:59
 **/
public class AuthToken extends UsernamePasswordToken {
    private static final long serialVersionUID = 3315864475370696149L;
    private String token;

    public AuthToken(String token) {
        this.token = token;
    }

    public AuthToken(String username, String password) {
        super(username, password);
    }

    @Override
    public Object getPrincipal() {
        return token;
    }

    @Override
    public Object getCredentials() {
        return token;
    }

    /**
     * 创建token的静态方法
     * @param username 用户名
     * @param password 密码
     * @return AuthToken对象
     */
    public static AuthToken of(String username, String password) {
        return new AuthToken(username, password);
    }
}
